package spittr.data;

import org.springframework.stereotype.Repository;
import spittr.model.Spitter;

import java.util.ArrayList;
import java.util.List;

@Repository
public class MockSpitterRepository implements SpitterRepository {
    private List<Spitter> spitters = new ArrayList<>();

    @Override
    public Spitter save(Spitter spitter) {
        spitters.add(spitter);
        return spitter;
    }

    @Override
    public Spitter findByUsername(String username) {
        for (Spitter spitter : spitters) {
            if (username.equals(spitter.getUsername())) {
                return spitter;
            }
        }

        return null;
    }
}
